<meta charset="utf-8" />
<div class="breadcrumbs" id="breadcrumbs">
	<ul class="breadcrumb">
		<li><i class="ace-icon fa fa-home home-icon"></i> <a href="index">主页</a>
		</li>

		<li><span>控制台</span></li>
	</ul>
	<!-- /.breadcrumb -->
</div>


<div class="page-content">

	<div class="col-xs-12">

		<div class="tabbable">
			<!-- Only required for left/right tabs -->
			<ul class="nav nav-tabs">
				<li class="active"><a href="#tab1" data-toggle="tab">排产计划</a></li>
				<li><a href="#tab2" data-toggle="tab" onclick="javascript:jhjk();">计划监控</a></li><!--点击异步刷新这个选项卡  -->
			</ul>
			<div class="tab-content">
				<div class="tab-pane active" id="tab1">


					<div class="table-header">
					
					日生产计划编号&nbsp;&nbsp;<b id="rscjhbh">${shijian!''}</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					选择显示日期&nbsp;&nbsp;&nbsp;<input name="xsrq1" type="text" onClick="WdatePicker()"  id="rq1" style="width:140px;height:38px" />
					</div>


					<div class="row">
						<div class="widget">
							<div class="widget-main">
								<form id="selefrom" class="form-inline" action="" method="post">
									生产订单号&nbsp;&nbsp;<input type="search" class="form-control input-sm"
										 aria-controls="dynamic-table" name="scddh" onfocus="clears()" id="qaz1">
										
										存货编码&nbsp;&nbsp;<input type="search" class="form-control input-sm"
										 aria-controls="dynamic-table" name="chbm" onfocus="clears()" id="qaz2">
											 
									<button id="selectfromsb" class="btn btn-info btn-sm">查询</button>
									
									<div class="pull-right"> 
									  <a id="xd" href="" class="btn btn-mini btn-primary"style="width:100px;height:31px">下达计划</a>
									  <a id="shanchu" href="" class="btn btn-mini btn-primary" style="width:50px;height:31px">删除</a>
									   <!-- <a href="#" class="btn btn-mini btn-primary" style="width:50px;height:31px">打印</a>
									  <a href="#" class="btn btn-mini btn-primary" style="width:50px;height:31px">导出</a> -->
							</div>
								</form>
							</div>
						</div>
					</div>




					<div id="interfaceList" class="row">
						<div class="col-xs-12">
							<!-- PAGE CONTENT BEGINS -->
							<div class="row">
								<div class="col-xs-12">
									<table class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable" role="grid">
										<!--id="simple-table"  -->
										<thead>
											<tr role="row">
											    <th class="center"><label> <input type="checkbox" class="ace" /> <span class="lbl"></span> </label></th>					
												<th class="hidden-480"><span>生产班组</span></th>
												<!-- <th class="hidden-480"><span>修改班组</span></th> -->
												<th class="hidden-480"><span>任务序号</span></th>
												<th class="hidden-480"><span>操作</span></th>
												<th class="hidden-480"><span>客户简称</span></th>
												<th class="hidden-480"><span>生产订单号</span></th>
												<th class="hidden-480"><span>存货编码</span></th>
												<th class="hidden-480"><span>存货名称</span></th>
												<th class="hidden-480"><span>规格型号</span></th>
												<th class="hidden-480"><span>单位</span></th>
												<th class="hidden-480"><span>计划排产数</span></th>
												<th class="hidden-480"><span>任务状态</span></th>
												<th class="hidden-480"><span>加单</span></th>
												<!-- <th class="hidden-480"><span>修改状态</span></th> -->
												
											</tr>
										</thead>
										<tbody id="Table_1"> </tbody>
									</table>

								</div>
								<!-- /.col -->
							</div>
							
							 <div class="breadcrumbs" id="breadcrumbs">    		 <!-- 第一个分页 -->
							 
							 <div class="col-xs-6">
						   	   <div class="dataTables_length" id="dynamic-table_length">
												<label>显示 <select name="selectname"
													aria-controls="dynamic-table" class="selectclass">
														<option value="10">10</option>
														<option value="20">20</option>
														<option value="50">50</option>
														<option value="100">100</option>
												</select> 记录
												</label>
											</div>
							  </div>
							 
								<div class="text-right">
					
						<!-- 默认显示一行的div -->
										<div class="dataTables_paginate paging_simple_numbers"
											id="dynamic-table_paginate1">
											<ul class="pagination" id="get_pagination1">
												
											</ul>
											<div name="laypage1.3" class="laypage_main laypageskin_molv"
													id="laypage_1">
													<span class="laypage_curr" style="background-color:#2283C5">1</span><span
														class="laypage_total"><label>到第</label><input
														max="1" min="1" class="laypage_skip" type="number"><label>页</label>
														<button type="button" class="laypage_btn">确定</button></span>
											</div>
										</div>
					</div><!--分页结束标志  -->
							 </div>     							                       
						</div>
						<!-- /.page-content -->

					</div>
				</div>


<script type="text/javascript">
function jhjk(){ 
 showPage2(1);
} 

</script>


<script type="text/javascript">
/*选择显示日期  1*/
$("#rq1").blur(function() {
var xsrq1=$("#rq1").val();
	//alert(xsrq1=='null');
if(xsrq1!=''){
//alert("输入日期不为空！！！");
 var str1="";
 str1 +=xsrq1.substring(0,4);
 str1 +=xsrq1.substring(5,7);
 str1 +=xsrq1.substring(8,11);
 $("#rscjhbh").text(str1);
 
 
$.post("cpjh/sele",{"xsrq1":xsrq1},function(data){//data表示接收后台传递的参数,"wwgs":z,
			
			showPage1(1,xsrq1);
			//PC_Plan(data);
			//PageFoot1(data[0].paginate); 		   //调用的PageFoot方法，循环输出页码连接  
	});
}else if(xsrq1==null||xsrq1=='null'||xsrq1==''){
  //alert("输入日期为空！！！");
                                var now = new Date(); //获取当前时间----------------
				                var year = now.getFullYear(); //年
								var month = now.getMonth() + 1; //月
								var day = (now.getDate()+1); //日
								var clock = year + "-";
								if (month < 10)
									clock += "0";
								clock += month + "-";
								if (day < 10)
									clock += "0";
								clock += day + " ";
								var str1="";
                                str1 +=clock.substring(0,4);
                                str1 +=clock.substring(5,7);
                                str1 +=clock.substring(8,11); 
 //var str1="20160919";//判断获得系统第二天的日期
  $("#rscjhbh").text(str1);

}	
	return false; 
});



		

/*  function clickEdit0(obj0){
	var id= obj0.attr("jhpcsid");//与前边相对应
	var jhpcs=$("#jhpcs"+id).val();
	
	 $.post("cpjh/jhpcsEdit",{"jhpcs": jhpcs,"id":id},function(){//data表示接收后台传递的参数,"wwgs":z,
			//wwgs.val(data);
	}); 
}  */


/*未下达计划的进行下达  */
	$("#xd").click(function(event){
		var ls = $("input[type=checkbox]:checked").size();   		//选中的个数
            if (ls != "") {
            	
                layer.confirm('确定下达计划？', {
		  			btn: ['确认','取消'] //按钮
					}, function(){
					var idlist='';
					$("input[type='checkbox'][name='checkboxs']").filter(':checked').each(function() {
                idlist = idlist + $(this).val() + ",";
                });
                if(idlist.length>0){
                idlist = idlist.substring(0,idlist.length-1);
                $.post("cpjh/xiada",{"idlist":idlist},function(data){
                	if(data=="success"){
                	var xsrq1=$("#rq1").val();/*!!!!!!!!!!!!!!!!!!!!!!!!!非常重要！！！！！！！！！！！！！！！！！！！！！  */
			        showPage1(1,xsrq1);//调用函数刷新页面
                	
                		//showPage1(1);//调用函数刷新页面
                		layer.closeAll('dialog');//关闭所有弹窗
	                		//location.reload();//重新载入本页面
                		idlist='';
                	}
                	else if(data=="fail"){
                	alert("pdm中没用对应产品或未分配工艺，不能下达！！！");
                	//var xsrq1=$("#rq1").val();
			        //showPage1(1,xsrq1);//调用函数刷新页面
                	
                		//showPage1(1);//调用函数刷新页面
                		layer.closeAll('dialog');//关闭所有弹窗
	                		//location.reload();//重新载入本页面
                		idlist='';
                	}
                });
                }
				layer.colse();
		}, function(){
			layer.msg("已取消"); 
		});
            } else {
                layer.alert("请选择要下达计划的数据！");
            }
	return false;
	});
	
	
	/*批量删除生产计划 */
	$("#shanchu").click(function(event){
		var ls = $("input[type=checkbox]:checked").size();   		//选中的个数
            if (ls != "") {
            	
                layer.confirm('确定删除计划？', {
		  			btn: ['确认','取消'] //按钮
					}, function(){
					var idlist='';
					$("input[type='checkbox'][name='checkboxs']").filter(':checked').each(function() {
                idlist = idlist + $(this).val() + ",";
                });
                if(idlist.length>0){
                idlist = idlist.substring(0,idlist.length-1);
                $.post("cpjh/delete",{"idlist":idlist},function(data){
                	if(data=="success"){
                	var xsrq1=$("#rq1").val();/*!!!!!!!!!!!!!!!!!!!!!!!!!非常重要！！！！！！！！！！！！！！！！！！！！！  */
			        showPage1(1,xsrq1);//调用函数刷新页面
                	
                		//showPage1(1);//调用函数刷新页面
                		layer.closeAll('dialog');//关闭所有弹窗
	                		//location.reload();//重新载入本页面
                		idlist='';
                	}else if(data=="fail"){               	
                	alert("产品正在生产，不能删除！！！");               	
                		layer.closeAll('dialog');//关闭所有弹窗	                		
                		idlist='';
                	}
                });
                }
				layer.colse();
		}, function(){
			layer.msg("已取消"); 
		});
            } else {
                layer.alert("请选择要删除的数据！");
            }
	return false;
	});
	
	
	


/*对生产计划监控进行闭单  */
	$("#bd").click(function(event){
		var ls = $("input[type=checkbox]:checked").size();   		//选中的个数
            if (ls != "") {
            	
                layer.confirm('确定闭单？', {
		  			btn: ['确认','取消'] //按钮
					}, function(){
					var idlist='';
					$("input[type='checkbox'][name='checkboxs2']").filter(':checked').each(function() {
                idlist = idlist + $(this).val() + ",";
                });
                if(idlist.length>0){
                idlist = idlist.substring(0,idlist.length-1);
                $.post("cpjh/bidan",{"idlist":idlist},function(data){
                	if(data=="success"){
			        showPage2(1);//调用函数刷新页面
                	
                	    //showPage2(1);//调用函数刷新页面
                	    layer.closeAll('dialog');//关闭所有弹窗
                		//location.reload();
                		idlist='';
                	}
                });
                }
				layer.colse();
		}, function(){
			layer.msg("已取消"); 
		});
            } else {
                layer.alert("请选择要闭单的计划！");
            }
	return false;
	});
	

	
	
//判断复选框是否被选中	       	
		$('table th input:checkbox').on('click' , function(){   		 /*复选框js_全选  */
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
		});
</script>

<script type="text/javascript">
/*第一部分  */
//鼠标经过变色
$("table").delegate("tr","mouseover",function(){  
            $(this).addClass("tr-mouseover");  
            $(this).css("background-color","#307ecc");   
        });   
    $("table").delegate("tr","mouseout",function(){  
        $(this).removeClass("tr-mouseover");  
        $(this).css("background-color","");  
    });

//查询时输入框以外的输入框清空
function clears(){
	document.getElementById("qaz1").value="";
	document.getElementById("qaz2").value="";
}
	$("#selectfromsb").click(function(){
					$.post("cpjh/sele1",$("#selefrom").serialize(),function(data){					
					showPage1(1,xsrq1);
				  //PageFoot1(data[0].paginate); 	
					});
					return false;
					});


 function aa() {//当刷新页面时重新执行查询方法
		$.post("cpjh/sele1",$("#selefrom").serialize(),function(data){
					showPage1(1,xsrq1);
		});
		}
aa();//调用查询方法



function PC_Plan(data) {				//生产计划
			var dataStr = "";
			$.each(data, function(i, a) {
				$.each(a.paginate.list, function(i, v) {  //v. _ rscjh表数据   a.paginate.list -->v
					dataStr += '<tr>';	
					dataStr += '<td><input class="ace" name="checkboxs" id="checkboxs" type="checkbox" value="'+v.id+'"> <span class="lbl"></span></td>';  	//<form name="pc1" action="cpjh/PC1" method="post"></form>
					
					   dataStr += '<td>';	
					$.each(a.scbz, function(i, n) {   	  //  n. _scbz表     a.scbz --> n
						if(n.dept_id==v.scbzbh)
						if(n.dept_name==null||n.dept_name=='null'||n.dept_name==''){
						dataStr += '';		//生产班组名称(部门表)
						}else{
						dataStr += n.dept_name;		//生产班组名称(部门表)
						}
					});	
					/* dataStr+='<div class="hidden-sm hidden-xs action-buttons"><a class="green" href="javascript:updateForm('+v.id+')"> <i class="ace-icon fa fa-pencil bigger-130"></i> </a>'; */
					dataStr += '</td>';
					
 //dataStr += '<td><input type="hidden" value="'+v.id+'" /><select name="selevalue"  scbzid="'+v.id+'" class="scbzbbb form-control" style="width:80px"  id="selevalue'+v.id+'"><option value="10" >表贴组</option><option value="11" >仪表组</option><option value="12" >电器盒组</option><option value="13" >电子组</option><option value="14" >电瓶仓组</option><option value="15"  >开关组</option></select></td>';
					    
					    if(v.zxbh==null||v.zxbh=='null'||v.zxbh==''){
					    dataStr += '<td>' + '' + '</td>';   //执行编号
					    }else{
						dataStr += '<td>' + v.zxbh + '</td>';   //执行编号
						}
						dataStr += '<td><div class="hidden-sm hidden-xs action-buttons"><a href="javascript:switchup('+v.id+')"> <span class="glyphicon glyphicon-arrow-up"></span> </a><a href="javascript:switchdown('+v.id+')"> <span class="glyphicon glyphicon-arrow-down"></span> </a> </div></td>';
						
						/*  $("#selevalue"+v.id+" option[value='"+v.scbzbh+"']").attr("selected",true); */
						
					dataStr += '<td>';
					$.each(a.scdd, function(i, m) {       // m. _scdd表数据  a.scdd --> m
						if(m.scddh==v.scddh)
						if(m.khjc==null||m.khjc=='null'||m.khjc==''){
						dataStr += '';   	 //客户简称
						}else{ 
						dataStr += m.khjc;   	 //客户简称
						}
					});	
					dataStr += '</td>';
					
					if(v.scddh==null||v.scddh=='null'||v.scddh==''){
					dataStr += '<td>'+''+'</td>';
					}else{
					dataStr += '<td>'+v.scddh+'</td>';
					}
					
					if(v.chbm==null||v.chbm=='null'||v.chbm==''){
					dataStr += '<td>' +  + '</td>';
					}else{
					dataStr += '<td>' + v.chbm + '</td>';
					}
				
					dataStr += '<td>';	
					$.each(a.scdd, function(i, m) {
						if(m.scddh==v.scddh)
						if(m.chmc==null||m.chmc=='null'||m.chmc==''){
						dataStr += '';	//存货名称
						}else{
						dataStr += m.chmc;	//存货名称
						}
					});	
					dataStr += '</td>';	
					
					dataStr += '<td>';	
					$.each(a.scdd, function(i, m) {
						if(m.scddh==v.scddh)
						if(m.ggxh==null||m.ggxh=='null'||m.ggxh==''){
						dataStr += '';	//规格型号
						}else{
						dataStr += m.ggxh;	//规格型号
						}
					});	
					dataStr += '</td>';
					
					dataStr += '<td>';	
					$.each(a.scdd, function(i, m) {
						if(m.scddh==v.scddh)
						if(m.dw==null||m.dw=='null'||m.dw==''){
						dataStr += '';   	//单位
						}else{
						dataStr += m.dw;   	//单位
						}
					});	
					dataStr += '</td>';
					
					
						//计划排产数（默认处于可编辑状态）
						/* dataStr += '<td><div class="col-sm-13"><input type="hidden" value="'+v.id+'" /><input name="jhpcs" type="text" jhpcsid="'+v.id+'" class="jhpcsaaa form-control " style="width:45px"  id="jhpcs'+v.id+'" value="'+v.jhpcs+'" /></div></td>'; */
						
						if(v.jhpcs==null||v.jhpcs=='null'||v.jhpcs==''){
						dataStr += '<td>' + '' + '</td>';//计划排产数
						}else{
						dataStr += '<td>' + v.jhpcs + '</td>';//计划排产数
						}
						
						if(v.rwxdzt==null||v.rwxdzt=='null'||v.rwxdzt==''){
						dataStr += '<td>' + '' + '</td>';//任务下达状态
						}else{
						dataStr += '<td>' + v.rwxdzt + '</td>';//任务下达状态
						}
						
						var jd=v.jhxdzt;
						var b=1;
						var c='加';
						var jiadan=jd-b;
						//var jiadan1=c+jiadan;
						dataStr +='<td class="hidden-480">';//计划下达状态（计划加单）
						if(jiadan<=0){
						var jiadan2='未';
						dataStr +=jiadan2;
						}else{
						dataStr += '<span class="label label-sm label-danger">';//当加单时变换背景色
						dataStr +=c;
						dataStr +='</span>';
						}
						dataStr +='</td>';
						 //dataStr += '<td>' + jiadan1 + '</td>';		//计划下达状态（计划加单）
						
						//dataStr += '<td>' + v.xgzt + '</td>';		//修改状态
						
					//dataStr += '<td><form id="rks" name="rks" action="scjhgl/yrks/'+v.id+'"?><input name="yrks" type="text" value="'+v.yrks+'"/></form></td>';   
						
					dataStr += '</tr>';
				});
			});
			//return dataStr;
			$("#Table_1").html(dataStr);
			
			$("#Table_1 .jhpcsaaa").blur(function() {//计划排产数
		clickEdit0($(this));
		return false;
		});
		
		/* $("#Table_1 .scbzbbb").blur(function() {//生产班组
		clickEdit1($(this));
		
		return false;
		}); */
}

function clickEdit0(obj0){
    //var jh=v.jhpcs;
	var id= obj0.attr("jhpcsid");//与前边相对应
	
	var jhpcs=$("#jhpcs"+id).val();
	
	if (!isNaN(jhpcs)){
	
	
	$.post("cpjh/jhpcsEdit",{"jhpcs": jhpcs,"id":id},function(data){//data表示接收后台传递的参数,"wwgs":z,
	       if(data=="error"){
	       alert("产品正在生产或已完成，不能进行修改！！！");
	       //layer.msg("产品正在生产或已完成，不能进行修改！！！");
	       var xsrq1=$("#rq1").val();/*!!!!!!!!!!!!!!!!!!!!!!!!!非常重要！！！！！！！！！！！！！！！！！！！！！  */
		   showPage1(1,xsrq1);//调用函数刷新页面  
	       return false;
	       }
	       
			//wwgs.val(data);
	});
	
	}else{
	 layer.msg("请输入正确的数据格式或范围！！！");
  }  
}

/* function clickEdit1(obj1){
	var id= obj1.attr("scbzid");//与前边相对应
	var selevalue=$("#selevalue"+id).val();//获取生产班组编号
	
	 $.post("cpjh/jhpcsEdit1",{"selevalue": selevalue,"id":id},function(){//data表示接收后台传递的参数,"wwgs":z,
	 		var xsrq1=$("#rq1").val();/*!!!!!!!!!!!!!!!!!!!!!!!!!非常重要！！！！！！！！！！！！！！！！！！！！！  */
			 //showPage1(1,xsrq1);//调用函数刷新页面                                                                //wwgs.val(data);
	//}); 
//} 
		


/*删除生产计划  */
          function Delete(id) {
        	 		if(id!=null){
	                layer.confirm("确定删除？", function () {
	                $.post("cpjh/delete?id="+id,function(data){
	                	if(data=="success"){
	                	
	                	var xsrq1=$("#rq1").val();/*!!!!!!!!!!!!!!!!!!!!!!!!!非常重要！！！！！！！！！！！！！！！！！！！！！  */
			            showPage1(1,xsrq1);//调用函数刷新页面  
	                	    //showPage1(1);//调用函数刷新页面
	                		//location.reload();//重新载入本页面
	                	}
	                });
	                     //$.updateByUrl("scjhgl/d?id="+id);
	                });
	               }else{
	               	layer.alert("请选择要删除的数据！");
	              }
	        }


/*修改(上升)执行编号  */
function switchup(id) {
        	 		if(id!=null){
	               /*  layer.confirm("确定向上调序？", function () { */
	                $.post("cpjh/switchup?id="+id,function(data){
	                	if(data=="success"){
	                	var xsrq1=$("#rq1").val();/*!!!!!!!!!!!!!!!!!!!!!!!!!非常重要！！！！！！！！！！！！！！！！！！！！！  */
			            showPage1(1,xsrq1);//调用函数刷新页面
	                	    //showPage1(1);//调用函数刷新页面
	                		//location.reload();//重新载入本页面
	                	}else if(data=="fail"){
                	alert("您的操作有误，不能再向上调整！！！");
                	var xsrq1=$("#rq1").val();/*!!!!!!!!!!!!!!!!!!!!!!!!!非常重要！！！！！！！！！！！！！！！！！！！！！  */
			        showPage1(1,xsrq1);//调用函数刷新页面
                	
                		//showPage1(1);//调用函数刷新页面
                		layer.closeAll('dialog');//关闭所有弹窗
	                		//location.reload();//重新载入本页面
                		idlist='';
                	}
	                });           
	                //});
	               }else{
	               	layer.alert("请选择要调序的数据！");
	              }
	        }


/*修改(下调)执行编号  */
function switchdown(id) {
        	 		if(id!=null){
	                //layer.confirm("确定向下调序？", function () {
	                $.post("cpjh/switchdown?id="+id,function(data){
	                	if(data=="success"){
	                	var xsrq1=$("#rq1").val();/*!!!!!!!!!!!!!!!!!!!!!!!!!非常重要！！！！！！！！！！！！！！！！！！！！！  */
			            showPage1(1,xsrq1);//调用函数刷新页面
	                	    //showPage1(1);//调用函数刷新页面
	                		//location.reload();//重新载入本页面
	                	}else if(data=="fail"){
                	alert("您的操作有误，不能再向下调整！！！");
                	var xsrq1=$("#rq1").val();/*!!!!!!!!!!!!!!!!!!!!!!!!!非常重要！！！！！！！！！！！！！！！！！！！！！  */
			        showPage1(1,xsrq1);//调用函数刷新页面
                	
                		//showPage1(1);//调用函数刷新页面
                		layer.closeAll('dialog');//关闭所有弹窗
	                		//location.reload();//重新载入本页面
                		idlist='';
                	}
	                });           
	                //});
	               }else{
	               	layer.alert("请选择要调序的数据！");
	              }
             }

	        


		
function PageFoot1(data){
//alert(data.totalPage);
			if(data.totalPage!=1){
				$("#laypage_1").addClass("hide");
				$("#get_pagination1").removeClass("hide");
				laypage({				
				cont : $('#get_pagination1'), //容器。值支持id名、原生dom对象，jquery对象,
				pages : data.totalPage, //总页数
				skip : true, //是否开启跳页
				skin : '#2283C5',//保持ace中间的样式;
				first: 1,
				last : data.totalPage, //总页数，将尾页显示为总页数
				curr : data.pageNumber,//当前页
				groups : 5, //连续显示分页数
				jump : function(obj, first) {
					if (!first) { //一定要加此判断，否则初始时会无限刷新
					//alert(obj.curr);
						//oldpageChange(obj.curr);
						showPage1(obj.curr,xsrq1);
					}
					}
				});
			}else{
				$("#get_pagination1").addClass("hide");
				$("#laypage_1").removeClass("hide");
			}
			
			
	}//分页方法结束标志



		
		function showPage1(curr,xsrq1) {  
			$.get("cpjh/Tbody_list1", {"pageNumber": curr,"xsrq1":xsrq1,"size":$(".selectclass").val()}, function(data) {
						PC_Plan(data);
				PageFoot1(data[0].paginate); 		   //调用的PageFoot方法，循环输出页码连接  	
			});
		}
		 var xsrq1="";
		 //showPage1(1,xsrq1);   		//刚进入页面为第一页，列出第一页数据和页脚 
		 
		 
		  $(".selectclass").change(function() {
			
			$.post("cpjh/select_records",{"select":$(".selectclass").val()}, function(data) {
			
			 showPage1(1,xsrq1);
			 });
		     });
		
	     	$("option").click(function() {
		
		    });
		
		
		
		
/*第二部分  */

//查询时输入框以外的输入框清空
function clears1(){
	document.getElementById("clear1").value="";
	document.getElementById("clear2").value="";
	document.getElementById("qaz3").value="";
	document.getElementById("qaz4").value="";
	document.getElementById("clear3").value="";
}

function clears2(){
	document.getElementById("clear2").value="";
	document.getElementById("qaz3").value="";
	document.getElementById("qaz4").value="";
	document.getElementById("clear3").value="";
}


$("#selectfromsb2").click(function(){
					$.post("cpjh/sele2",$("#selefrom2").serialize(),function(data){
					
					showPage2(1);
					//PageFoot2(data[0].paginate); 	

					});
					return false;
					});
					
					

		function PC_JK(data) {				//计划监控
			var dataStr = "";
			$.each(data, function(i, a) {
				$.each(a.paginate.list, function(i, v) {  //v. _ rscjh表数据   a.paginate.list -->v
					dataStr += '<tr>';	
					dataStr += '<td><input class="ace" name="checkboxs2" id="checkboxs2" type="checkbox" value="'+v.id+'"> <span class="lbl"></span></td>';  	//<form name="pc1" action="cpjh/PC1" method="post"></form>
					//dataStr += '<td>' + v.rscjhbh + '</td>';   //日生产计划编号
					
					if(v.scddh==null||v.scddh=='null'||v.scddh==''){
					dataStr += '<td>'+''+'</td>';//生产订单号	
					}else{	
					dataStr += '<td>'+v.scddh+'</td>';//生产订单号
					}	
						
					dataStr += '<td>';
					$.each(a.scdd, function(i, m) {       // m. _scdd表数据  a.scdd --> m
						if(m.scddh==v.scddh)
						if(m.khjc==null||m.khjc=='null'||m.khjc==''){
						dataStr += '';   	 //客户简称
						}else{ 
						dataStr += m.khjc;   	 //客户简称
						}
					});	
					dataStr += '</td>';
					
					if(v.chbm==null||v.chbm=='null'||v.chbm==''){
					dataStr += '<td>' + '' + '</td>';//存货编码
					}else{
					dataStr += '<td>' + v.chbm + '</td>';//存货编码
					}
					
					dataStr += '<td>';	
					$.each(a.scdd, function(i, m) {
						if(m.scddh==v.scddh)
						if(m.chmc==null||m.chmc=='null'||m.chmc==''){
						dataStr += '';	//存货名称
						}else{
						dataStr += m.chmc;	//存货名称
						}
					});	
					dataStr += '</td>';	
					
					dataStr += '<td>';	
					$.each(a.scdd, function(i, m) {
						if(m.scddh==v.scddh)
						if(m.ggxh==null||m.ggxh=='null'||m.ggxh==''){
						dataStr += '';	//规格型号
						}else{
						dataStr += m.ggxh;	//规格型号
						}
					});	
					dataStr += '</td>';
					
					dataStr += '<td>';	
					$.each(a.scdd, function(i, m) {
						if(m.scddh==v.scddh)
						if(m.dw==null||m.dw=='null'||m.dw==''){
						dataStr += '';   	//单位
						}else{
						dataStr += m.dw;   	//单位
						}
					});	
					dataStr += '</td>';
					
					dataStr += '<td>';	
					$.each(a.scbz, function(i, n) {   	  //  n. _scbz表     a.scbz --> n
						if(n.dept_id==v.scbzbh)
						if(n.dept_name==null||n.dept_name=='null'||n.dept_name==''){
						dataStr += '';		//生产班组名称(部门表)
						}else{ 
						dataStr += n.dept_name;		//生产班组名称(部门表)
						}
					});	
					dataStr += '</td>';
					
					//dataStr += '<td>' + v.zxbh + '</td>';   //执行编号
					
					if(v.jhpcs==null||v.jhpcs=='null'||v.jhpcs==''){
					dataStr += '<td>' + '' + '</td>';    //计划排产数
					}else{
					dataStr += '<td>' + v.jhpcs + '</td>';    //计划排产数
					}
					//dataStr += '<td>' + v.ypcs + '</td>';    //已排产数
					
					if(v.rwxdzt==null||v.rwxdzt=='null'||v.rwxdzt==''){
					dataStr += '<td>' + '' + '</td>';    //任务下达状态
					}else{
					dataStr += '<td>' + v.rwxdzt + '</td>';    //任务下达状态
					}
					
					
					var now = new Date(); //获取当前时间----------------
								var year = now.getFullYear(); //年
								var month = now.getMonth()+1; //月
								var day = (now.getDate()); //日
								var clock = year + "-";
								if (month < 10)
									clock += "0";
								clock += month + "-";
								if (day < 10)
									clock += "0";
								clock += day + " "; 
					//alert(clock);
					
					/* $.ajax({
				type:"post",
				url:"cpjh/bidan",
				async : false,
				data:{"scddh":clock,"pcbzbh":v.pcbzbh,"id":v.id},
				success :function(data){
					wcsl=data;//获取后台传递的累计完工数
				}
			}); */
						
			dataStr += '<td><div class="col-sm-13"><input type="hidden" value="'+v.id+'" /><input name="wcrq" type="text"  useid="'+v.id+'" class="form-control" style="width:90px"  id="wcrq'+v.id+'" value="'+clock+'"  /></div></td>';
			//完成日期
						
			//dataStr += '<td><div class="col-sm-13"><input name="ywgs" type="text" useid="'+v.id+'" class="form-control editButton" style="width:40px"  id="ywgs'+v.id+'" value="'+v.ywgs+'" /></div></td>';
			
			dataStr += '<td>';	
			$.each(a.xcc, function(i, n) {   	  //  n. _scbz表     a.scbz --> n
					if(n.scxh==v.scxh) dataStr += n.xccsl;//现场仓半成品信息表
					//var bb=n.xccsl;
					//alert(bb);
						
			});	
			dataStr += '</td>';
			//已完工数
			
			/* var wwgs=0;
			$.ajax({
				type:"post",
				url:"scjhgl/jisuan",
				async : false,
				data:{"scddh":v.scddh,"pcbzbh":v.pcbzbh,"id":v.id},
				success :function(data){
					wcsl=data;//获取后台传递的累计完工数
				}
			}); */
			
			
			dataStr += '<td>';	
			$.each(a.xcc, function(i, n) {   	  //  n. _scbz表     a.scbz --> n
					if(n.scxh==v.scxh) dataStr += v.jhpcs-n.xccsl;//获得未完工数量	
			});
			dataStr += '</td>';
							
			// dataStr += '<td><div class="col-sm-13"><input name="wwgs" type="text" class="form-control" id="wwgs'+v.id+'" style="width:40px"  value="'+v.wwgs+'" disabled="disabled" /></div></td>';
			//未完工数						               			
			/* dataStr += '<td><a class="btn btn-mini btn-primary" href="javascript:PC_1('+v.id+')">录入</a></td>'; */
			//操作			
			//dataStr += '<td><input type="hidden" value="'+v.id+'" /><select name="selevalue1"   style="width:95px" class="form-control"   id="selevalue1'+v.id+'"><option value="表贴组" >表贴组</option><option value="仪表组" >仪表组</option><option value="电器盒组" >电器盒组</option><option value="电子组" >电子组</option><option value="电瓶仓组" >电瓶仓组</option><option value="开关组"  >开关组</option></select><input name="rscjhbh" type="text" onClick="WdatePicker()" placeholder="排产日期"  class="form-control" style="width:95px"  id="rscjhbh'+v.id+'"  /><input name="jhpcs1" jhpcs1id="'+v.id+'" class="jhpcs1bbb form-control" placeholder="计划排产数"  style="width:95px"  id="jhpcs1'+v.id+'"   /></td>';
			//下一班组,日期和计划排产数量			
			});
		});				
						
			//return dataStr;
			$("#Table_2").html(dataStr);
		
	}
	

		
function PageFoot2(data){
//alert(data.totalPage);
			if(data.totalPage!=1){
				$("#laypage_2").addClass("hide");
				$("#get_pagination2").removeClass("hide");
				laypage({				
				cont : $('#get_pagination2'), //容器。值支持id名、原生dom对象，jquery对象,
				pages : data.totalPage, //总页数
				skip : true, //是否开启跳页
				skin : '#2283C5',//保持ace中间的样式;
				first: 1,
				last : data.totalPage, //总页数，将尾页显示为总页数
				curr : data.pageNumber,//当前页
				groups : 5, //连续显示分页数
				jump : function(obj, first) {
					if (!first) { //一定要加此判断，否则初始时会无限刷新
					//alert(obj.curr);
						//oldpageChange(obj.curr);
						showPage2(obj.curr);
					}
					}
				});
			}else{
				$("#get_pagination2").addClass("hide");
				$("#laypage_2").removeClass("hide");
			}
			
			
	}//分页方法结束标志
		
		function showPage2(curr) {  
			$.get("cpjh/Tbody_list2", {"pageNumber": curr,"size1":$(".selectclass1").val()}, function(data) {
				PC_JK(data);
				PageFoot2(data[0].paginate); 		   //调用的PageFoot方法，循环输出页码连接  
				//}
			});
		}
		
		 showPage2(1);   		//刚进入页面为第一页，列出第一页数据和页脚 
		 
		 
		 $(".selectclass1").change(function() {
			
			$.post("cpjh/select_records",{"select":$(".selectclass1").val()}, function(data) {
			
			showPage2(1);
			 });
		     });
		
	     	$("option").click(function() {
		
		    });
		
		
		
		
											
/* function PC_1(q) {
	
						var t="zzzz_wcrq"+q;
						var p="zzzz_ywgs"+q;
						var x=document.getElementById(t).value;
						var y=document.getElementById(p).value;
						//alert(x);
						//alert(y);
						
					$.post("cpjh/luru",{"wcrq":x,"ywgs":y,"id":q},function(data){//data表示接收后台传递的参数,"wwgs":z,
							layer.msg(data);
					});
        } */
</script>
							
										
				<!-- <p>I'm in Section 1.</p> -->
				<div class="tab-pane" id="tab2">

					<div class="table-header">
					
					已下达的生产计划<!-- 日生产计划编号&nbsp;&nbsp;<b id="rscjhbh2">${shijian2!''}</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
					选择日期&nbsp;&nbsp;&nbsp;<input name="xsrq2" id="rq2" type="text" onClick="WdatePicker()" style="width:140px;height:38px" /> -->
					</div>


					<div class="row">
						<div class="widget">
							<div class="widget-main">
								<form id="selefrom2" class="form-inline" action="" method="post">
								计划生产日期&nbsp;&nbsp;<input type="search" onClick="WdatePicker()"  style="width:100px; class="form-control input-sm"
										 aria-controls="dynamic-table" name="rscjhbh" onfocus="clears2()" id="clear1" >
								计划生产班组&nbsp;&nbsp;<input type="search"  style="width:60px; class="form-control input-sm"
										 aria-controls="dynamic-table" name="scbzmc" onfocus="clears1()" id="clear2">																
									生产订单号&nbsp;&nbsp;<input type="search"  style="width:100px; class="form-control input-sm"
										 aria-controls="dynamic-table" name="scddh" onfocus="clears1()" id="qaz3">
										
										存货编码&nbsp;&nbsp;<input type="search"  style="width:100px; class="form-control input-sm"
										 aria-controls="dynamic-table" name="chbm" onfocus="clears1()" id="qaz4">
										 计划状态&nbsp;&nbsp;<input type="search"  style="width:60px; class="form-control input-sm"
										 aria-controls="dynamic-table" name="rwxdzt" onfocus="clears1()" id="clear3">
											 
									<button id="selectfromsb2" class="btn btn-info btn-sm" style="width:50px;height:31px">查询</button>
									<div class="pull-right">
									  <!-- <a  id=pc_dh href=""  class="btn btn-mini btn-primary"style="width:50px;height:31px">排产</a> -->
									  <a id="bd" href="" class="btn btn-mini btn-primary"style="width:100px;height:31px">关闭计划</a> 
							        </div>
<script type="text/javascript">
	/* function pc_dh(){

		showPage2(1);//调用函数刷新页面
		//alert(132);														
	}; */
	
	
	/*对下一生产班组计划进行排产  */
	$("#pc_dh").click(function(event){
		var ls = $("input[type=checkbox]:checked").size();   		//选中的个数
            if (ls != "") {
            	
                layer.confirm('确定排产？', {
		  			btn: ['确认','取消'] //按钮
					}, function(){
					var idlist='';
					$("input[type='checkbox'][name='checkboxs2']").filter(':checked').each(function() {
                idlist = idlist + $(this).val() + ",";
                });
                if(idlist.length>0){
                idlist = idlist.substring(0,idlist.length-1);
                $.post("cpjh/paichan2",function(data){
                	if(data=="success"){              	
			        showPage2(1);//调用函数刷新页面
                	    //showPage2(1);//调用函数刷新页面
                	    layer.closeAll('dialog');//关闭所有弹窗
                		//location.reload();
                		idlist='';
                	}
                } );
                }
				layer.colse();
		}, function(){
			layer.msg("已取消"); 
		});
            } else {
                layer.alert("请选择要排产的数据！");
            }
	return false;
	});
</script>
								</form>
							</div>
						</div>
					</div>




					<div class="row">
						<div class="col-xs-12">
							<!-- PAGE CONTENT BEGINS -->
							<div class="row">
							
								<div class="col-xs-12">
									<table class="table table-striped table-bordered table-hover dataTable no-footer DTTT_selectable" role="grid">
										<thead>
											<tr role="row">
											    <th class="center"><label> <input type="checkbox" class="ace" /> <span class="lbl"></span> </label></th>
											    <!-- <th class="hidden-480"><span>日生产计划编号</span></th> -->
												<th class="hidden-480"><span>生产订单号</span></th>
												<th class="hidden-480"><span>客户简称</span></th>											   
												<th class="hidden-480"><span>存货编码</span></th>
												<th class="hidden-480"><span>存货名称</span></th>
												<th class="hidden-480"><span>规格型号</span></th>
												<th class="hidden-480"><span>单位</span></th>
												<th class="hidden-480"><span>生产班组</span></th>
												<!-- <th class="hidden-480"><span>任务编号</span></th>		 -->									 
												<th class="hidden-480"><span>计划排产数</span></th>
												<th class="hidden-480"><span>任务状态</span></th>
												<th class="hidden-480"><span>完成日期</span></th>	
												<th class="hidden-480"><span>已完工数</span></th>
												<th class="hidden-480"><span>未完工数</span></th>																							
                                               <!--  <th class="hidden-480"><span>下一班组和日期</span></th> -->
											</tr>
										</thead>
										
										<tbody id="Table_2"></tbody>
									</table>
								</div>
								
							</div>
							
							 <div class="breadcrumbs" id="breadcrumbs">    		 <!--第二个分页 -->
							 
							  <div class="col-xs-6">
											<div class="dataTables_length" id="dynamic-table_length">
												<label>显示 <select name="selectname1"
													aria-controls="dynamic-table" class="selectclass1">
														<option value="10">10</option>
														<option value="20">20</option>
														<option value="50">50</option>
														<option value="100">100</option>
												</select> 记录
												</label>
											</div>
							</div>
							 
							 
								<div class="text-right">
					
						<!-- 默认显示一行的div -->
										<div class="dataTables_paginate paging_simple_numbers"
											id="dynamic-table_paginate1">
											<ul class="pagination" id="get_pagination2">
												
											</ul>
											<div name="laypage1.3" class="laypage_main laypageskin_molv"
													id="laypage_2">
													<span class="laypage_curr" style="background-color:#2283C5">1</span><span
														class="laypage_total"><label>到第</label><input
														max="1" min="1" class="laypage_skip" type="number"><label>页</label>
														<button type="button" class="laypage_btn">确定</button></span>
											</div>
										</div>
					</div><!--分页结束标志  -->
					
							 </div>    				
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<script>
					/*需要引用的js固定方法  */
					jQuery(function($) {
						$
								.widget(
										"ui.dialog",
										$
												.extend(
														{},
														$.ui.dialog.prototype,
														{
															_title : function(
																	title) {
																var $title = this.options.title
																		|| '&nbsp;';
																if (("title_html" in this.options)
																		&& this.options.title_html == true)
																	title
																			.html($title);
																else
																	title
																			.text($title);
															}
														}));
						//initiate dataTables plugin
						var oTable1 = $('#dynamic-table')
						//.wrap("<div class='dataTables_borderWrap' />")   //if you are applying horizontal scrolling (sScrollX)
						.dataTable(
								{
									bAutoWidth : false,
									"aoColumns" : [ null, null, null, null,
											null, null, {
												"bSortable" : false
											} ],
									"aaSorting" : [],

								//,
								//"sScrollY": "200px",
								//"bPaginate": false,

								//"sScrollX": "100%",
								//"sScrollXInner": "120%",
								//"bScrollCollapse": true,
								//Note: if you are applying horizontal scrolling (sScrollX) on a ".table-bordered"
								//you may want to wrap the table inside a "div.dataTables_borderWrap" element

								//"iDisplayLength": 50
								});
						//oTable1.fnAdjustColumnSizing();

						//TableTools settings
						TableTools.classes.container = "btn-group btn-overlap";
						TableTools.classes.print = {
							"body" : "DTTT_Print",
							"info" : "tableTools-alert gritter-item-wrapper gritter-info gritter-center white",
							"message" : "tableTools-print-navbar"
						};

						//initiate TableTools extension
						var tableTools_obj = new $.fn.dataTable.TableTools(
								oTable1,
								{
									"sSwfPath" : "plugins/ace/assets/js/dataTables/extensions/TableTools/swf/copy_csv_xls_pdf.swf", //in Ace demo plugins/ace/assets will be replaced by correct assets path

									"sRowSelector" : "td:not(:last-child)",
									"sRowSelect" : "multi",
									"fnRowSelected" : function(row) {
										//check checkbox when row is selected
										try {
											$(row).find('input[type=checkbox]')
													.get(0).checked = true;
										} catch (e) {
										}
									},
									"fnRowDeselected" : function(row) {
										//uncheck checkbox
										try {
											$(row).find('input[type=checkbox]')
													.get(0).checked = false;
										} catch (e) {
										}
									},

									"sSelectedClass" : "success",
									"aButtons" : [
											{
												"sExtends" : "copy",
												"sToolTip" : "复制到剪贴板",
												"sButtonClass" : "btn btn-white btn-primary btn-bold",
												"sButtonText" : "<i class='fa fa-copy bigger-110 pink'></i>",
												"fnComplete" : function() {
													this
															.fnInfo(
																	'<h3 class="no-margin-top smaller">表格已复制</h3>\
							<p>已复制 '
																			+ (oTable1
																					.fnSettings()
																					.fnRecordsTotal())
																			+ ' 行数据到剪贴板.</p>',
																	1500);
												}
											},

											{
												"sExtends" : "csv",
												"sToolTip" : "导出成 CSV",
												"sButtonClass" : "btn btn-white btn-primary  btn-bold",
												"sButtonText" : "<i class='fa fa-file-excel-o bigger-110 green'></i>"
											},

											{
												"sExtends" : "pdf",
												"sToolTip" : "导出成 PDF",
												"sButtonClass" : "btn btn-white btn-primary  btn-bold",
												"sButtonText" : "<i class='fa fa-file-pdf-o bigger-110 red'></i>"
											},

											{
												"sExtends" : "print",
												"sToolTip" : "打印页面",
												"sButtonClass" : "btn btn-white btn-primary  btn-bold",
												"sButtonText" : "<i class='fa fa-print bigger-110 grey'></i>",

												"sMessage" : "<div class='navbar navbar-default'><div class='navbar-header pull-left'><a class='navbar-brand' href='#'><small>可选导航栏 &amp; 文本</small></a></div></div>",

												"sInfo" : "<h3 class='no-margin-top'>打印页面</h3>\
							  <p>请用您的浏览器打印功能打印这个表格 \
							  <br />请打印完成关闭此页面</p>",
											} ]
								});
						//we put a container before our table and append TableTools element to it
						/* $(tableTools_obj.fnContainer()).appendTo($('.tableTools-container')); */

						//also add tooltips to table tools buttons
						//addding tooltips directly to "A" buttons results in buttons disappearing (weired! don't know why!)
						//so we add tooltips to the "DIV" child after it becomes inserted
						//flash objects inside table tools buttons are inserted with some delay (100ms) (for some reason)
						setTimeout(function() {
							$(tableTools_obj.fnContainer()).find(
									'a.DTTT_button').each(function() {
								var div = $(this).find('> div');
								if (div.length > 0)
									div.tooltip({
										container : 'body'
									});
								else
									$(this).tooltip({
										container : 'body'
									});
							});
						}, 200);

						//ColVis extension
						var colvis = new $.fn.dataTable.ColVis(oTable1, {
							"buttonText" : "<i class='fa fa-search'></i>",
							"aiExclude" : [ 0, 6 ],
							"bShowAll" : true,
							//"bRestore": true,
							"sAlign" : "right",
							"fnLabel" : function(i, title, th) {
								return $(th).text();//remove icons, etc
							}

						});

						//style it
						$(colvis.button()).addClass('btn-group').find('button')
								.addClass('btn btn-white btn-info btn-bold');
						//and append it to our table tools btn-group, also add tooltip
						$(colvis.button()).prependTo(
								'.tableTools-container .btn-group').attr(
								'title', '显示/隐藏 数据列').tooltip({
							container : 'body'
						});

						//and make the list, buttons and checkboxed Ace-like
						$(colvis.dom.collection)
								.addClass(
										'dropdown-menu dropdown-light dropdown-caret dropdown-caret-right')
								.find('li').wrapInner(
										'<a href="javascript:void(0)" />') //'A' tag is required for better styling
								.find('input[type=checkbox]').addClass('ace')
								.next().addClass('lbl padding-8');

						/////////////////////////////////
						//table checkboxes
						$('th input[type=checkbox], td input[type=checkbox]')
								.prop('checked', false);

						//select/deselect all rows according to table header checkbox
						$(
								'#dynamic-table > thead > tr > th input[type=checkbox]')
								.eq(0)
								.on(
										'click',
										function() {
											var th_checked = this.checked;//checkbox inside "TH" table header

											$(this)
													.closest('table')
													.find('tbody > tr')
													.each(
															function() {
																var row = this;
																if (th_checked)
																	tableTools_obj
																			.fnSelect(row);
																else
																	tableTools_obj
																			.fnDeselect(row);
															});
										});

						//select/deselect a row when the checkbox is checked/unchecked
						$('#dynamic-table').on(
								'click',
								'td input[type=checkbox]',
								function() {
									var row = $(this).closest('tr').get(0);
									if (!this.checked)
										tableTools_obj.fnSelect(row);
									else
										tableTools_obj.fnDeselect($(this)
												.closest('tr').get(0));
								});

						$(document).on('click',
								'#dynamic-table .dropdown-toggle', function(e) {
									e.stopImmediatePropagation();
									e.stopPropagation();
									e.preventDefault();
								});

						//And for the first simple table, which doesn't have TableTools or dataTables
						//select/deselect all rows according to table header checkbox
						var active_class = 'active';
						$(
								'#simple-table > thead > tr > th input[type=checkbox]')
								.eq(0)
								.on(
										'click',
										function() {
											var th_checked = this.checked;//checkbox inside "TH" table header

											$(this)
													.closest('table')
													.find('tbody > tr')
													.each(
															function() {
																var row = this;
																if (th_checked)
																	$(row)
																			.addClass(
																					active_class)
																			.find(
																					'input[type=checkbox]')
																			.eq(
																					0)
																			.prop(
																					'checked',
																					true);
																else
																	$(row)
																			.removeClass(
																					active_class)
																			.find(
																					'input[type=checkbox]')
																			.eq(
																					0)
																			.prop(
																					'checked',
																					false);
															});
										});

						//select/deselect a row when the checkbox is checked/unchecked
						$('#simple-table').on('click',
								'td input[type=checkbox]', function() {
									var $row = $(this).closest('tr');
									if (this.checked)
										$row.addClass(active_class);
									else
										$row.removeClass(active_class);
								});

						/********************************/
						//add tooltip for small view action buttons in dropdown menu
						$('[data-rel="tooltip"]').tooltip({
							placement : tooltip_placement
						});

						//tooltip placement on right or left
						function tooltip_placement(context, source) {
							var $source = $(source);
							var $parent = $source.closest('table');							var off1 = $parent.offset();
							var w1 = $parent.width();

							var off2 = $source.offset();
							//var w2 = $source.width();

							if (parseInt(off2.left) < parseInt(off1.left)
									+ parseInt(w1 / 2))
								return 'right';
							return 'left';
						};

					});
					
					
				</script>
